﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;
namespace Data
{
   public class ChucVuRepository
    {
       public static ChucVuDTO GetChuVu(int maChucVu)
       {
           NhaSachEntities context = new NhaSachEntities();
           var q = (from cv in context.ChucVuList
                    where cv.MaChucVu == maChucVu
                    select new ChucVuDTO()
                    {
                        MaChucVu = cv.MaChucVu,
                        TenChucVu = cv.TenChucVu,
                        Quyen = (int)cv.Quyen,
                        TinhTrang =(int) cv.TinhTrang
                    }).FirstOrDefault();
           return q;
       }
       public static List<ChucVuDTO> GetChucVuList()
       {
           NhaSachEntities context = new NhaSachEntities();
           var q = (from cv in context.ChucVuList
                    select new ChucVuDTO()
                    {
                        MaChucVu = cv.MaChucVu,
                        TenChucVu = cv.TenChucVu,
                        Quyen = (int)cv.Quyen,
                        TinhTrang = (int)cv.TinhTrang
                    }).DefaultIfEmpty();
           return q.ToList();

       }
    }
}
